package xyz.xtt.user.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import xyz.xtt.asset.client.AssetClient;
import xyz.xtt.asset.client.response.AssetInfoResponse;
import xyz.xtt.common.response.ApiResult;
import xyz.xtt.equity.client.EquityClient;
import xyz.xtt.pay.client.PayClient;
import xyz.xtt.user.service.IInnerService;

@Slf4j
@Service
public class IInnerServiceImpl implements IInnerService {
	@Autowired
	private AssetClient assetClient;
	@Autowired
	private EquityClient equityClient;
	@Autowired
	private PayClient payClient;

	@Override
	public Long queryPutOn(String uid) {
		ApiResult<Long> queryPutOn = assetClient.queryPutOn(uid);
		log.info("assetClient queryPutOn response:{}", JSONUtil.toJsonStr(queryPutOn));
		return ApiResult.convert(queryPutOn, 0L);
	}

	@Override
	public Boolean isVip(Long appUid) {
		ApiResult<Boolean> response = equityClient.isVip(appUid);
		log.info("equityClient isVip response:{}", JSONUtil.toJsonStr(response));
		return ApiResult.convert(response, Boolean.FALSE);
	}

	@Override
	public AssetInfoResponse infoWithGoodsId(String goodsId) {
		ApiResult<AssetInfoResponse> response = assetClient.infoWithGoodsId(goodsId);
		log.info("assetClient infoWithGoodsId response:{}", JSONUtil.toJsonStr(response));
		return ApiResult.convert(response, null);
	}

	@Override
	public Boolean skipRealPay() {
		ApiResult<Boolean> response = payClient.skipRealPay();
		log.info("payClient skipRealPay response:{}", JSONUtil.toJsonStr(response));
		return ApiResult.convert(response, Boolean.FALSE);
	}
}
